package com.lenovo.lcdm.common.enums;

/**
 * common response enum
 * @author
 */
public enum CommonMsgEnum {
    SUCCESS(0, "成功"),
    FAIL(-1, "失败"),
    UNKNOWN(-2, "未知错误"),
    PARAMETER_ERROR(-3, "参数校验失败"),

    S3_CREATE_SSL_CTX_FAILED(4001, "Create S3 SSL Context failed"),
    UPLOAD_FILE_FAILED(4002, "Upload File Failed"),
    GET_FILE_FAILED(4003, "Get File Failed"),
    DELETE_FILE_FAILED(4004, "DELETE File Failed"),
    ATTACHMENT_NOT_EXIST(4005, "Attachment not exist"),
    ATTACHMENT_EXPORT_FAILED(4006, "Export Attachment Failed"),
    ATTACHMENT_LINK_EXIST(4006, "Attachment already link to object"),

    TOO_CONTAINS_ALL_PARAMETERS_INPUT(4007, "Too Many Contains All Parameter, limit: 50"),
    TOO_CONTAINS_ANY_PARAMETERS_INPUT(4008, "Too Many Contains Any Parameter, limit: 10"),

    TOKEN_INVALID(1000, "Invalid Token, Please Check!"),
    USER_NOT_LOGIN(1001, "User Not Login"),
    USER_NOT_EXIST(1002, "User Not Exist, %s"),
    USER_NOT_AUTH(1003, "User Not Permission"),

    CONCURRENT_CONFLICT(2002, "Database concurrent conflict"),
    FREEMARKER_WRITE_FAILED(3001, "Write to freemarker template failed"),


    ;
    private int code;
    private String message;
    CommonMsgEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public String formatMsg(Object... args) {
        return String.format(getMessage(), args);
    }
}
